<template>
  <div class="swiper-box">
    <div class="mokuai1">
      <swiper ref="mySwiper"  :options="swiperOptions" @someSwiperEvent="callback">
        <!-- slides -->
        <swiper-slide v-for="item of swiperList" :key="item.id">
          <img class="swiper-img" :src="item.imgUrl" alt="去哪儿门票" />
        </swiper-slide>
        <!-- Optional controls -->
        <div class="swiper-pagination" slot="pagination"></div>
        <!-- <div class="swiper-button-prev" slot="button-prev"></div>
        <div class="swiper-button-next" slot="button-next"></div>
        <div class="swiper-scrollbar" slot="scrollbar"></div>-->
      </swiper>
    </div>
  </div>
</template>

<script>
export default {
  // name: "swiper", 打开报错，暂时不知原因，只知道name的原因
  //es6的写法，相当于data:function(){return{swiperOption:{}}}
  data() {
    return {
      swiperOptions: {
        // some swiper options/callbacks
        // 所有的参数同 swiper 官方 api 参数
        // 参数选项,显示小点
        pagination: ".swiper-pagination",
        //循环
        loop: true
        //每张播放时长3秒，自动播放
        // autoplay: 2000,
        //滑动速度
        // speed: 1000
        // delay:1000
      },
      // 循环图片
      swiperList: [
        {
          id: "001",
          imgUrl:
            "http://img1.qunarzz.com/piao/fusion/1805/d4/d41d77b6ba8aca02.jpg_750x200_ac3d9a73.jpg"
        },
        {
          id: "002",
          imgUrl:
            "http://img1.qunarzz.com/piao/fusion/1805/f1/e57bc93226317102.jpg_750x200_9ab37bd0.jpg"
        },
        {
          id: "003",
          imgUrl:
            "http://img1.qunarzz.com/piao/fusion/1804/c4/1cdd28811593b802.jpg_750x200_5fbb7c91.jpg"
        }
      ]
    };
  },
  computed: {
    swiper() {
      return this.$refs.mySwiper.swiper;
      // return this.imgList.length
    }
  },
  mounted() {
    // current swiper instance
    // 然后你就可以使用当前上下文内的swiper对象去做你想做的事了
    // console.log("this is current swiper instance object", this.swiper);
    // this.swiper.slideTo(3, 1000, false);
  },
  //
  methods: {
    callback() {
      console.log(dianji);
    }
  }
};
</script>

<style>
</style>